﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Fast.Framework.Interfaces;


namespace Fast.Framework
{

    /// <summary>
    /// 插入构造者
    /// </summary>
    public class InsertBuilder : IInsertBuilder
    {

        /// <summary>
        /// 表名称
        /// </summary>
        public string TableName { get; set; }

        /// <summary>
        /// 列
        /// </summary>
        public string Columns { get; set; }

        /// <summary>
        /// 值
        /// </summary>
        public string Value { get; set; }

        /// <summary>
        /// 是否批量
        /// </summary>
        public bool IsBatch { get; set; }

        /// <summary>
        /// 参数
        /// </summary>
        public Dictionary<string, object> Parameters { get; }

        /// <summary>
        /// 参数列表
        /// </summary>
        public List<Dictionary<string, object>> ParametersList { get; }

        /// <summary>
        /// 构造方法
        /// </summary>
        public InsertBuilder()
        {
            Parameters = new Dictionary<string, object>();
            ParametersList = new List<Dictionary<string, object>>();
        }

        /// <summary>
        /// 到字符串
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.AppendLine($"INSERT INTO {TableName}");
            sb.AppendLine("(");
            sb.AppendLine(Columns);
            sb.AppendLine(")");
            sb.AppendLine("VALUES");
            sb.AppendLine("(");
            sb.AppendLine(Value);
            sb.AppendLine(")");
            //Console.WriteLine(sb.ToString().Trim());
            return sb.ToString().Trim();
        }
    }
}
